package at.ac.tuwien.mg.wh.model;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Min;


@Entity
@IdClass(ItemUserKey.class)
public class ItemUser implements Serializable {
	
	@Id
	@ManyToOne
	private User user;
	@Id
	@ManyToOne
	private Item item;
	
	@Id
	@Enumerated(EnumType.STRING)
	private ItemState state = ItemState.BOOKED;
	
	@Min(0)
	private Integer number = 0;

	private static final long serialVersionUID = 1L;

	public ItemUser(){
		
	}
		
	public ItemUser(Item item, User user, Integer number) {
		super();
		this.item = item;
		this.user = user;
		this.number = number;
	}

	public Item getItem() {
		return item;
	}



	public void setItem(Item item) {
		this.item = item;
	}



	public User getUser() {
		return user;
	}



	public void setUser(User user) {
		this.user = user;
	}



	public Integer getNumber() {
		return number;
	}



	public void setNumber(Integer number) {
		this.number = number;
	}



	public ItemState getState() {
		return state;
	}



	public void setState(ItemState state) {
		this.state = state;
	}

	@Override
	public String toString() {
		return "ItemUser [item=" + item.getCatalogId() + ", user=" + user.getUserId() + ", number="
				+ number + ", state=" + state + "]";
	}



   
}
